#ifndef INODE_H_
#define INODE_H_

#include <cassert>
#include "FileSystem.h"
#include "types.h"

/* encoding of inode type in di_mode (upper 4 of 16 bits) */
#define		X_IFMT	0170000	/* type of file (mask upper 4 bits) */
#define		X_IFIFO 0010000 /* FIFO special file */
#define		X_IFCHR	0020000	/* character special */
#define		X_IFMPC	0030000	/* multiplexed char special */
#define		X_IFDIR	0040000	/* directory */
#define		X_IFBLK	0060000	/* block special */
#define		X_IFMPB	0070000	/* multiplexed block special */
#define		X_IFREG	0100000	/* regular */

/* flags in di_mode (lower 12 bits of 16) */
#define	X_ISUID		0004000	/* set user id on execution */
#define	X_ISGID		0002000	/* set group id on execution */
#define	X_ISVTX		0001000	/* save swapped text even after use */

#define	X_IUREAD	0000400	/* read permission, owner */
#define	X_IUWRITE	0000200	/* write permission, owner */
#define	X_IUEXEC	0000100	/* execute/search permission, owner */

#define	X_IGREAD	0000040	/* read permission, group */
#define	X_IGWRITE	0000020	/* write permission, group */
#define	X_IGEXEC	0000010	/* execute/search permission, group */

#define	X_IOREAD	0000004	/* read permission, other */
#define	X_IOWRITE	0000002	/* write permission, other */
#define	X_IOEXEC	0000001	/* execute/search permission, other */

class FileSystem;

class Inode {
private:
	long	filesize;
	short 	mode;
	short   nLinks;
	int 	number;
	int		usecount;
	long 	blockList[13];
	FileSystem* filesystem;

public:

	Inode(FileSystem* filesystem, byte *data, int number);
	virtual ~Inode();

	short	getType();
	short 	getMode();
	short   getNumberOfLinks();
	long 	getFileSize();
	long*	getBlockList();
	long	getBlocknummer(long position);
	int		getNumber();
	void 	toString();
	int		getUsecount();
	void	usecountIncrement();
	void 	release();
};

#endif
